home *** CD-ROM | disk | FTP | other *** search
Wrap
(*^ ::[paletteColors = 128; currentKernel; fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e8, 24, "Times"; ; fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e6, 18, "Times"; ; fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, L1, e6, 14, "Times"; ; fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, L1, a20, 18, "Times"; ; fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, L1, a15, 14, "Times"; ; fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, L1, a12, 12, "Times"; ; fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 10, "Times"; ; fontset = input, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L1, 12, "Courier"; ; fontset = output, output, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier"; ; fontset = message, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = print, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = info, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, L1, 12, "Courier"; ; fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, L1, 10, "Times"; ; fontset = header, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = Left Header, nohscroll, cellOutline, 12; fontset = footer, inactive, nohscroll, noKeepOnOnePage, preserveAspect, center, M7, L1, 12; fontset = Left Footer, cellOutline, blackBox, 12; fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 10, "Times"; ; fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12, "Courier"; ; fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12;] :[font = title; inactive; Cclosed; preserveAspect; startGroup; ] Lab 10: Vector Calculus :[font = section; inactive; Cclosed; preserveAspect; startGroup; ] Two-Dimensional Vector Fields :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] This new version of Mathematica includes a package for plotting vector fields. The following command loads the package for two-dimensional vector fields: ;[s] 3:0,0;20,1;31,2;154,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect; endGroup; ] <<Graphics/PlotField.m :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Example :[font = text; inactive; preserveAspect; ] Here is a fairly simple two-dimensional vector field: :[font = input; preserveAspect; ] F[x_,y_] := { y, x } :[font = text; inactive; preserveAspect; ] This, of course, means: F(x,y) = y i + x j . :[font = text; inactive; preserveAspect; ] If we interpret F[x,y] to be the wind velocity at the point {x,y}, then this says that the velocity at the point {1,-2} is {-2,1}. :[font = text; inactive; preserveAspect; ] The PlotVectorField command shows what it looks like: :[font = input; preserveAspect; ] PlotVectorField[ F[x,y], {x,-2,2}, {y,-2,2} ]; :[font = text; inactive; preserveAspect; endGroup; ] To locate the vector at the point {1,-2}, select the graph (click on it), and then drag the mouse cursor across it while holding down the Command key. The coordinates of the cursor will be displayed at the bottom right corner of the window. Move the cursor until these coordinates are {1,-2.001}. At that location on the plot you should see a little arrow whose direction is {-2,1}. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Exercises :[font = text; inactive; preserveAspect; ] For each of the following, draw the vector field over the domain specified, and then use the Command-drag technique to check the vector at the point (1,-2): :[font = text; inactive; preserveAspect; ] 1. F[x_,y_] := { -y, x } over -2 <= x <= 2 and -2 <= y <= 2 . :[font = text; inactive; preserveAspect; endGroup; endGroup; ] 2. F[x_,y_] := { y / Sqrt[x^2+y^2], x / Sqrt[x^2+y^2] } over -2 <= x <= 2 and -2 <= y <= 2 . :[font = section; inactive; Cclosed; pageBreak; preserveAspect; startGroup; ] Gradient Fields and Hamiltonian Fields :[font = text; inactive; preserveAspect; ] The gradient of a scalar field is a vector field. It is called the gradient field of the scalar field, and the scalar field is called a potential function for the vector field. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Example :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Here is a simple scalar field: :[font = input; preserveAspect; ] f[x_,y_] := x^2 + y^2 :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] and this is its gradient vector field: :[font = input; preserveAspect; endGroup; ] F[x_,y_] = { D[f[x,y],x], D[f[x,y],y] } :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Here's a plot of this gradient field: :[font = input; preserveAspect; endGroup; endGroup; ] PlotVectorField[ F[x,y], {x,-2,2}, {y,-2,2} ]; :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] The PlotGradientField command (in the same PlotField package) plots the gradient field F of a given potential funtion f directly, thereby obviating the need to find F first: :[font = input; preserveAspect; endGroup; ] PlotGradientField[ f[x,y], {x,-2,2}, {y,-2,2} ] :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] The PlotHamiltonianField command (also in the PlotField package) plots the Hamiltonian field H of a given potential funtion f: :[font = input; preserveAspect; endGroup; endGroup; ] PlotHamiltonianField[ f[x,y], {x,-2,2}, {y,-2,2} ] :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Exercises :[font = text; inactive; preserveAspect; ] Plot both the Gradient field and the Hamiltonian field for each of the following potential functions. Then explain how the two are related: :[font = text; inactive; preserveAspect; ] 1. f[x_,y_] := x^2 - y^2 over -2 <= x <= 2 and -2 <= y <= 2 . :[font = text; inactive; preserveAspect; endGroup; endGroup; ] 2. f[x_,y_] := Sin[x] Cos[y] over -Pi <= x <= 2Pi and -Pi <= y <= Pi . :[font = section; inactive; Cclosed; pageBreak; preserveAspect; startGroup; ] Streamlines :[font = text; inactive; preserveAspect; ] Recall that the gradient vector always points in the direction of maximum increase of a function. Therefore the gradient will always be perpendicular to the function's level curves because they consist of all points where the function has the same value. :[font = text; inactive; preserveAspect; ] This new version of Mathematica allows the user to specify which level curves are to be drawn by the ContourPlot command. This allows us to see more clearly the relationships between a function's gradient field, its Hamiltonian field, and its level curves. ;[s] 3:0,0;20,1;31,2;257,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Example :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Here's the same example we used above: :[font = input; preserveAspect; ] f[x_,y_] := x^2 + y^2 :[font = input; preserveAspect; endGroup; ] Plot3D[ f[x,y], {x,-2,2}, {y,-2,2} ]; :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Here again are its gradient and Hamiltonian fields: :[font = input; preserveAspect; ] gf = PlotGradientField[ f[x,y], {x,-2,2}, {y,-2,2} ]; :[font = input; preserveAspect; endGroup; ] hf = PlotHamiltonianField[ f[x,y], {x,-2,2}, {y,-2,2} ]; :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] And here they are together: :[font = input; preserveAspect; ] Show[ {gf,hf} ]; :[font = text; inactive; preserveAspect; endGroup; ] From this picture, we can clearly see that the two fields are orthogonal—that is, their vectors are perpendicular. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Now let's look at the level curve for f at the level z = 4: :[font = input; preserveAspect; ] cf = ContourPlot[ f[x,y], {x,-2,2}, {y,-2,2}, ContourShading -> False, ContourSmoothing -> Automatic, Contours -> {4} ] :[font = text; inactive; preserveAspect; ] Since the level curve is perpendicular to the gradient field at each point, it must be parallel to the Hamiltonian field at each point. This means that the level curve will be a streamline for the Hamiltonian vector field: :[font = input; preserveAspect; ] Show[ {hf,cf} ]; :[font = text; inactive; preserveAspect; endGroup; endGroup; ] If this vector field represents the wind's velocity vectors, then the curve will be the path of a particle controlled by that force. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Exercises :[font = text; inactive; preserveAspect; ] Use the ContourPlot command, as shown above, to draw the level curve at the given z-value. Then show the curve on the same picture with the function's Hamiltonian field. Use the output numbers of the plots that you did in the previous section. For example, if the first exercise was Out[23], then input: Show[ { %23, cf } ] :[font = text; inactive; preserveAspect; ] 1. f[x_,y_] := x^2 - y^2 over -2 <= x <= 2 and -2 <= y <= 2 , at z = 1. :[font = text; inactive; preserveAspect; endGroup; endGroup; ] 2. f[x_,y_] := Sin[x] Cos[y] over -Pi <= x <= 2Pi and -Pi <= y <= Pi , at z = 0.5 :[font = section; inactive; Cclosed; preserveAspect; startGroup; ] Three-Dimensional Vector Fields :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] The new version of Mathematica can also plot three-dimensional vector fields. Those commands are in the following package: ;[s] 3:0,0;19,1;30,2;123,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect; endGroup; ] <<Graphics/PlotField3D.m :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Example :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Here's Example 4 from page 809: :[font = input; preserveAspect; ] F[x_,y_,z_] := { x y z, x^2, -x y } :[font = input; preserveAspect; endGroup; ] PlotVectorField3D[ F[x,y,z], {x,-2,2}, {y,-2,2}, {z,-2,2} ]; :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] The package also includes a three-dimensional PlotGradientField command. Here's a plot of the gradient field of the potential function f (x,y,z) = xyz: :[font = input; preserveAspect; endGroup; endGroup; ] PlotGradientField3D[ x y z, {x,-1,1}, {y,-1,1}, {z,-1,1} ]; :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Exercises :[font = text; inactive; preserveAspect; ] 1. Plot the vector field defined in Exercise 4 on page 810. :[font = text; inactive; preserveAspect; endGroup; endGroup; ] 2. Plot the vector field defined in Exercise 3 on page 831. :[font = section; inactive; Cclosed; pageBreak; preserveAspect; startGroup; ] Vector Derivative Operators :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] The next external package that we need has some conflicts with the previous packages that we have already loaded. Consequently, you will have to quit the current kernel before loading the new package. Give the Quit/Disconnect Kernel… command (in the Action>Kernels submenu), and click on the Yes button to quit the kernel. Then load this package: :[font = input; preserveAspect; ] <<Calculus/VectorAnalysis.m :[font = text; inactive; preserveAspect; endGroup; ] It contains all the usual vector derivative opeators: Grad, Div, Curl, and Laplacian. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Example :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Here's Example 2 from page 807: :[font = input; preserveAspect; ] F[x_,y_,z_] := { 5x^2 y, x y, x^2 z } :[font = input; preserveAspect; ] F[x,y,z] :[font = input; preserveAspect; ] Div[ F[x,y,z] ] :[font = input; preserveAspect; endGroup; ] Curl[ F[x,y,z] ] :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Here's the definition of the gradient of a three-dimensional scalar field: :[font = input; preserveAspect; endGroup; ] Grad[ f[x,y,z] ] :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] And here's Mathematica's proof of the identity in Exercise 11 on page 810: ;[s] 3:0,0;11,1;22,2;74,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect; endGroup; endGroup; ] Curl[ Grad[ f[x,y,z] ] ] :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Exercises :[font = text; inactive; preserveAspect; ] 1. Exercise 1 on page 810. :[font = text; inactive; preserveAspect; ] 2. Exercise 7 on page 810. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] 3. Exercise 21 on page 811. Hint: define: :[font = input; preserveAspect; ] F[x_,y_,z_] := { P[x,y,z], Q[x,y,z], R[x,y,z] }; G[x_,y_,z_] := { S[x,y,z], T[x,y,z], U[x,y,z] }; :[font = text; inactive; preserveAspect; ] and then compare: :[font = input; preserveAspect; ] Div[ CrossProduct[ F[x,y,z], G[x,y,z] ] ] :[font = text; inactive; preserveAspect; ] with: :[font = input; preserveAspect; endGroup; endGroup; endGroup; endGroup; ] G[x,y,z].Curl[F[x,y,z]] - F[x,y,z].Curl[G[x,y,z]] ^*)